import { reactive } from 'vue'
import axios from 'axios'

const state = reactive({
  token: localStorage.getItem('accessToken') || null,
  refreshToken: localStorage.getItem('refreshToken') || null
})

export function updateToken() {
  return axios({
    url: '/member/auth/refreshToken',
    method: 'post',
    headers: {
      'Authorization': state.refreshToken,
    },
    params: {
      userId: localStorage.getItem('id'),
      username: localStorage.getItem('username')
    }
  });
}
